package com.atguigu.mapper;

import com.atguigu.bean.Department;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

// @Mapper
public interface DepartmentMapper {
    @Select("select * from department")
    public List<Department> getDepts();

    @Select("select * from department where id=#{id}")
    public Department getDeptById(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into department(department_name) values(#{departmentName})")
    public int insertDept(Department dept);

    @Update("update department set department_name=#{departmentName} where id=#{id}")
    public int updateDept(Department dept);

    @Delete("delete from department where id=#{id}")
    public int deleteDept(Integer id);
}
